package com.dhcc.sdc.cdss.controller;


import java.util.List;
import java.util.Map;


import com.dhcc.sdc.cdss.entity.SdcCdssNursingEntity;
import com.dhcc.sdc.cdss.service.ISdcCdssNursingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.baomidou.mybatisplus.plugins.Page;
import com.dhcc.core.framework.base.controller.BaseController;
import com.dhcc.core.framework.base.warpper.EmptyWarpper;
import com.dhcc.core.framework.exception.BizException;
import com.dhcc.core.framework.exception.BizExceptionEnum;
import com.dhcc.core.framework.result.R;
import com.dhcc.core.framework.result.page.PageFactory;
import com.dhcc.core.framework.util.CommonUtil;





/**
 * 
 * 
 * @ClassName: SdcCdssNursingController
 * @Description: TODO
 * @author zhangdc
 * @date 2022-06-23 15:27:31
 */
@Controller
@RequestMapping("${sys.backendPath}/sds/sdccdssnursing")
public class SdcCdssNursingController extends BaseController {

	private String PREFIX = "/backend/sds/sdccdssnursing/";

	@Autowired
	private ISdcCdssNursingService sdcCdssNursingService;

    /**
     * 获取列表
     */
	@SuppressWarnings("unchecked")
    @RequestMapping(value = "/list")
    @ResponseBody
    public Object list(@RequestParam Map<String, Object> params) {
		Page<SdcCdssNursingEntity> page = new PageFactory<SdcCdssNursingEntity>().defaultPage();
        List<SdcCdssNursingEntity> result = this.sdcCdssNursingService.page(page,params);
        page.setRecords((List<SdcCdssNursingEntity>) new EmptyWarpper(result).warp());
        return R.packForBT(page);
    }

    /**
     * 新增
     */
    @RequestMapping(value = "/add")
    @ResponseBody
    public Object add(SdcCdssNursingEntity sdcCdssNursing) {
        if (CommonUtil.isOneEmpty(sdcCdssNursing)) {
            throw new BizException(BizExceptionEnum.REQUEST_NULL);
        }
        sdcCdssNursing.insert();
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping(value = "/delete")
    @ResponseBody
    public Object delete(@RequestParam Long sdcCdssNursingId) {
	
        this.sdcCdssNursingService.deleteById(sdcCdssNursingId);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping(value = "/update")
    @ResponseBody
    public Object update(SdcCdssNursingEntity sdcCdssNursing) {
        if (CommonUtil.isOneEmpty(sdcCdssNursing)) {
            throw new BizException(BizExceptionEnum.REQUEST_NULL);
        }
        SdcCdssNursingEntity old = this.sdcCdssNursingService.selectById(sdcCdssNursing.getId());

        old.setItemId(sdcCdssNursing.getItemId());
        old.setQcentityId(sdcCdssNursing.getQcentityId());
        old.setItemName(sdcCdssNursing.getItemName());
        old.setItemDesc(sdcCdssNursing.getItemDesc());
        old.setSourceFlag(sdcCdssNursing.getSourceFlag());
        old.updateAllColumnById();
        return R.ok();
    }
	
}
